<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/4
 * Time: 9:43
 */

namespace app\admin\controller;


use app\admin\service\RequestService;
use cmf\controller\BaseController;

class MenuMxController extends BaseController
{
    private static $app_token='';
    private static $app_id='wxdd1f6dcd35660bdb';
    private static $app_secret='e98f5334ad604f1f610492b02686e7f0';
    public  function _initialize()
    {
        parent::_initialize(); // TODO: Change the autogenerated stub
        import('wechat.WechatOauth',EXTEND_PATH);
    }

    /**
     *
     */
    public function login()
    {
        $scope=$this->request->get('scope','snsapi_base'); //默认静默登录
        $appid='';
        $url='https://open.weixin.qq.com/connect/oauth2/authorize?
        appid=APPID
        &redirect_uri=REDIRECT_URI
        &response_type=code
        &scope=SCOPE
        &state=STATE
        #wechat_redirect ';
        return $this->redirect($url);
    }

    /**
     *
     */
    public  function callBack()
   {
        $code=$this->get('code','');
       if(!$code){
           return $this->getHome();
       }
       //通过code来获取网页授权access_token的值
        $url='';
       return 'i am back';
   }

}